#include "ObserveDocument.h"
#include "Logger/tri_logger.hpp"
#include "DocumentManager.h"
#include <QTextCursor>

ObserveDocument::ObserveDocument(DocumentManager* parent) : QTextDocument(parent){
	TRI_LOG_STR("WorkDokument");
	document_manager = parent;
}

ObserveDocument::~ObserveDocument()
{
}


void ObserveDocument::updateText(int position, int charsRemoved ,const QTextDocumentFragment f){
	TRI_LOG_STR("updateText");
	TRI_LOG(f.toPlainText ().toAscii().constData ());	
	TRI_LOG(charsRemoved);
	QTextCursor c = QTextCursor (this);
	c.beginEditBlock();
	c.setPosition (position, QTextCursor::MoveAnchor);
	while (charsRemoved--){
		c.deleteChar();
	}
	c.insertFragment(f);
	c.endEditBlock();
	
}


